home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
OS
/
ZCursor.h
< prev
next >
Wrap
Text File
|
1997-05-30
|
5KB
|
193 lines
/*
* File: ZCursor.h
* Summary: Mouse cursor classes.
* Written by: Jesse Jones
*
* Classes: TCursor - Encapsulates color and b/w cursors.
* UCursorUtils - Cursor utility functions.
* TForceBusyCursor - Stack based class to display a busy cursor.
* THideCursor - Stack based class to hide the cursor.
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 2/24/96 JDJ Created.
*/
#pragma once
#include <QuickDraw.h>
#include <ZGeometry.h>
#include <ZTypes.h>
//-----------------------------------
// Forward References
//
class ZCursorSpinner;
struct CursorDevice;
// ===================================================================================
// class TCursor
// ===================================================================================
class TCursor {
friend class UCursorUtils;
public:
~TCursor();
explicit TCursor(ResID id);
TCursor(const TCursor& rhs);
TCursor& operator=(const TCursor& rhs);
bool operator==(const TCursor& rhs) const {return mID == rhs.mID;}
bool operator!=(const TCursor& rhs) const {return mID != rhs.mID;}
bool operator<(const TCursor& rhs) const {return mID < rhs.mID;}
private:
CCrsrHandle mColorCursor;
Cursor* mBwCursor;
ResID mID;
};
// ===================================================================================
// Standard Cursors
// ===================================================================================
extern const TCursor kArrowCursor; // Standard cursors
extern const TCursor kCrossHairCursor;
extern const TCursor kIBeamCursor;
extern const TCursor kPlusCursor;
extern const TCursor kWatchCursor;
extern const TCursor kOpenHandCursor; // A few other common cursors
extern const TCursor kClosedHandCursor;
extern const TCursor kEyeDropperCursor;
extern const TCursor kBrushCursor;
extern const TCursor kPencilCursor;
extern const TCursor kSpinningWatchCursor; // Animated cursors
extern const TCursor kBeachBallCursor;
extern const TCursor kEmptyArrowCursor;
// ===================================================================================
// class UCursorUtils
// ===================================================================================
class UCursorUtils {
friend class TForceBusyCursor;
//-----------------------------------
// Initialization
//
public:
static void Init();
// Makes the cursor visible and sets it to kArrowCursor. Note
// that this can be called more than once.
//-----------------------------------
// Cursor Operations
//
public:
static void SetCursor(const TCursor& cursor);
// Changes the cursor and stops the busy cursor animation
// (if cursor != msBusyCursor).
static void ObscureCursor() {::ObscureCursor();}
// Hides the cursor until the mouse moves.
//-----------------------------------
// Busy Cursor
//
public:
static void StillBusy();
// Call this for long tasks to avoid timing out. Note that
// this does nothing if the busy cursor isn't already up.
static void ForceBusy();
// Puts up a busy cursor that animates until it times out or
// SetCursor is called with a different cursor.
static void ForceBusy(const TCursor& cursor);
static void SetTimeout(MilliSecond duration);
// Defaults to 5 seconds.
static MilliSecond GetTimeout();
static void InstallCustomBusyCursor(const TCursor& newCursor);
// Defaults to kSpinningWatchCursor.
//-----------------------------------
// Cursor Moving
//
public:
static TPoint GetPosition();
// Returns the mouse position in global coordinates.
static bool CanMove();
// Returns false if there's a cursor device that cannot be moved
// (like a TouchWindow).
static void MoveTo(short x, short y);
// Use global coordinates!
static void MoveBy(short dx, short dy);
// Move the mouse a relative distance.
//-----------------------------------
// Member data
//
private:
static TCursor msBusyCursor;
static TCursor msCurrentCursor;
static ZCursorSpinner* msCursorSpinner;
static CursorDevice* msCursorDevice;
static bool msCanMoveMouse;
};
// ===================================================================================
// class TForceBusyCursor
// ===================================================================================
class TForceBusyCursor {
public:
~TForceBusyCursor();
TForceBusyCursor();
TForceBusyCursor(const TCursor& cursor);
void StillBusy() {UCursorUtils::StillBusy();}
private:
TCursor mOldCursor;
bool mWasBusy;
};
// ===================================================================================
// class THideCursor
// ===================================================================================
class THideCursor {
public:
~THideCursor() {::ShowCursor();}
THideCursor() {::HideCursor();}
};